//
//  GTListItem.m
//  WKWebViewStudy
//
//  Created by Jason Len on 2019/9/18.
//  Copyright © 2019年 Jason. All rights reserved.
//

/**
 列表结构化数据
 */
#import "GTListItem.h"

@implementation GTListItem

#pragma mark - NSSecureCoding

- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if(self){
        self.category= [aDecoder decodeObjectForKey:@"category"];
        self.picUrl=[aDecoder decodeObjectForKey:@"picUrl"];
        self.uniqueKey=[aDecoder decodeObjectForKey:@"uniqueKey"];
        self.title =[aDecoder decodeObjectForKey:@"title"];
        self.date =[aDecoder decodeObjectForKey:@"date"];
        self.authorName=[aDecoder decodeObjectForKey:@"authorName"];
        self.articleUrl=[aDecoder decodeObjectForKey:@"articleUrl"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.category forKey:@"category"];
    [aCoder encodeObject:self.picUrl forKey:@"picUrl"];
    [aCoder encodeObject:self.uniqueKey forKey:@"uniqueKey"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.date forKey:@"date"];
    [aCoder encodeObject:self.authorName forKey:@"authorName"];
    [aCoder encodeObject:self.articleUrl forKey:@"articleUrl"];
}

+(BOOL)supportsSecureCoding{
    return YES;
}

#pragma mark - public method

-(void)configWithDictionary:(NSDictionary *)dictionary{
#warning 类型是否匹配
    self.category= [dictionary objectForKey:@"category"];
    self.picUrl=[dictionary objectForKey:@"thumbnail_pic_s"];
    self.uniqueKey=[dictionary objectForKey:@"uniqueKey"];
    self.title =[dictionary objectForKey:@"title"] ;
    self.date =[dictionary objectForKey:@"date"] ;
    self.authorName=[dictionary objectForKey:@"author_name"];
    self.articleUrl=[dictionary objectForKey:@"url"];
}

@end
